{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "08e56028",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'reqType': 0,\n",
       " 'perception': {'inputText': {'text': '附近的酒店'},\n",
       "  'inputImage': {'url': 'imageUrl'},\n",
       "  'selfInfo': {'location': {'city': '北京', 'province': '北京', 'street': '信息路'}}},\n",
       " 'userInfo': {'apiKey': '******', 'userId': '767214'}}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{\n",
    "\t\"reqType\":0,\n",
    "    \"perception\": {\n",
    "        \"inputText\": {\n",
    "            \"text\": \"附近的酒店\"\n",
    "        },\n",
    "        \"inputImage\": {\n",
    "            \"url\": \"imageUrl\"\n",
    "        },\n",
    "        \"selfInfo\": {\n",
    "            \"location\": {\n",
    "                \"city\": \"北京\",\n",
    "                \"province\": \"北京\",\n",
    "                \"street\": \"信息路\"\n",
    "            }\n",
    "        }\n",
    "    },\n",
    "    \"userInfo\": {\n",
    "        \"apiKey\": \"******\",\n",
    "        \"userId\": \"767214\"\n",
    "    }\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dc137e23",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests,json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2dd5c762",
   "metadata": {},
   "outputs": [],
   "source": [
    "TL_KEY = \"d5d5bb66f66d4da8bedb378df7adfa70\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d7f047b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "91b829f7",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unexpected indent (<ipython-input-8-4ea4c3cae738>, line 14)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-8-4ea4c3cae738>\"\u001b[1;36m, line \u001b[1;32m14\u001b[0m\n\u001b[1;33m    requests.post(TL_url,data = params)\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m unexpected indent\n"
     ]
    }
   ],
   "source": [
    "TL_url = \"http://openapi.turingapi.com/openapi/api/v2\"\n",
    "params = {\n",
    "        \"reqType\":0,\n",
    "        \"perception\": {\n",
    "            \"inputText\": {\n",
    "                \"text\": text\n",
    "            },\n",
    "        },\n",
    "        \"userInfo\": {\n",
    "            \"apiKey\": TL_KEY,\n",
    "            \"userId\": \"000001\"\n",
    "        }\n",
    "    }\n",
    "  requests.post(TL_url,data = params)\n",
    "    return res.json()['results'][0]['values']['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1184dc1b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
